package com.ashin.mq.listener;

import com.ashin.common.RabbitMQConfig;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Map;

import static com.ashin.common.RabbitMQConfig.BINDING_KEY_ORDER;
import static com.ashin.common.RabbitMQConfig.BINDING_KEY_GOOD;

@Component
@RabbitListener(bindings = {
        @QueueBinding(value = @Queue(value = RabbitMQConfig.QUEUE_TEST), exchange = @Exchange(RabbitMQConfig.EXCHANGE_DIRECT_TEST), key = {BINDING_KEY_ORDER}),
        @QueueBinding(value = @Queue(value = RabbitMQConfig.QUEUE_TEST), exchange = @Exchange(value = RabbitMQConfig.EXCHANGE_TOPIC_TEST, type = ExchangeTypes.TOPIC), key = {BINDING_KEY_GOOD}),
        @QueueBinding(value = @Queue(value = RabbitMQConfig.QUEUE_TEST), exchange = @Exchange(value = RabbitMQConfig.EXCHANGE_FANOUT_TEST, type = ExchangeTypes.FANOUT))
})
public class RabbitMQConsumer {


    @RabbitHandler
    public void handler(Map map) {
        System.out.println("收到消息" + map.toString());
    }

}
